define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'union/inaccount/index',
                    add_url: 'union/inaccount/add',
                    edit_url: 'union/inaccount/edit',
                    del_url: 'union/inaccount/del',
                    // multi_url: 'auth/admin/multi',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'out_type', title: __('支付方式'),searchList: {'1' : '支付宝','2' :'银行卡'}, formatter: Table.api.formatter.normal},
                        {field: 'username', title: __('用户名')},
                        {field: 'idcard', title: __('身份证号')},
                        {field: 'bank_name', title: __('银行名称')},
                        {field: 'payment', title: __('支付宝账号/银行卡号')},
                        {field: 'status', title: __('状态'),searchList: {'0':'审核中','3':'不通过','1' :'启用','2':'未启用'}, formatter: Table.api.formatter.normal},
                        {field: 'remark', title: __('审核原因')},
                        {field: 'created_at', title: '添加时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'updated_at', title: '更新时间', formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Form.api.bindevent($("form[role=form]"));
        },
        edit: function () {
            Form.api.bindevent($("form[role=form]"));
        }
    };
    return Controller;
});
